package com.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

@Getter
@AllArgsConstructor
public enum RoleEnum {

    USER(1, "user"),
    ASSISTANT(2, "assistant");


    private final Integer code;

    private final String desc;

    private static final Map<Integer, RoleEnum> MAP = new HashMap<>();

    static {
        for (RoleEnum roleEnum : values()) {
            MAP.put(roleEnum.getCode(), roleEnum);
        }
    }

    public static RoleEnum getEnumByCode(Integer code) {
        return MAP.get(code);
    }
}
